

class Persion(object):
    def __inif__(self):
        self.name = '小王'

    ##实例化方法一
    #def __new__(self):
    #    if not hasattr(Persion,'instance'):
    #        Persion.instance = object.__new__(self);
    #    return Persion.instance;
    
    
    #实例化方法二
    def __new__(self):
        if not hasattr(Persion,'instance'):
            Persion.instance = super(Persion,self).__new__(self);
        return Persion.instance;




if __name__ == '__main__':
    p1 = Persion();
    p2 = Persion();
    print(p1,p2)
    #print(p1.name, p2.name) #直接抛异常，因为Persion 这个类型没有进行过实例化，实例化的是 object.__new__();
    


